package maze;

import java.util.ArrayList;
import java.util.List;

/**
 * A class representing a sector.
 * A panel is represented by its walls.
 */
public class Sector {
	
	private boolean northWall;
	private boolean eastWall;
	private boolean southWall;
	private boolean westWall;
	
	public Sector(boolean north, boolean east, boolean south, boolean west){
		setNorthWall(north);
		setEastWall(east);
		setSouthWall(south);
		setWestWall(west);
	}

	public boolean hasNorthWall() {
		return northWall;
	}

	private void setNorthWall(boolean northWall) {
		this.northWall = northWall;
	}

	public boolean hasSouthWall() {
		return southWall;
	}

	private void setSouthWall(boolean southWall) {
		this.southWall = southWall;
	}

	public boolean hasEastWall() {
		return eastWall;
	}

	private void setEastWall(boolean eastWall) {
		this.eastWall = eastWall;
	}

	public boolean hasWestWall() {
		return westWall;
	}

	private void setWestWall(boolean westWall) {
		this.westWall = westWall;
	}
	
	protected void addWall(){
		//TODO
	}
	
	public String toString(){
		String res = "Panel with walls:";
		res += "\nNorth: ";
		res += new Boolean(hasNorthWall()).toString();
		res += "\nEast: ";
		res += new Boolean(hasEastWall()).toString();
		res += "\nSouth: ";
		res += new Boolean(hasSouthWall()).toString();
		res += "\nWest: ";
		res += new Boolean(hasWestWall()).toString();
		res += "\n";
		return res;
	}
	
	/**
	 * Adds a wall to this Panel
	 * 
	 * @param dir
	 * 			Indicates on what side of the panel the new wall is located.
	 */
	protected void addWall(Direction dir){
		switch(dir){
		case NORTH: 
			this.setNorthWall(true);
		case EAST: 
			this.setEastWall(true);
		case SOUTH: 
			this.setSouthWall(true);
		case WEST: 
			this.setWestWall(true);
		}
	}
	
	/**
	 * Removes a wall to this Panel
	 * 
	 * @param dir
	 * 			Indicates on what side of the panel the old wall is located.
	 */
	protected void removeWall(Direction dir){
		switch(dir){
		case NORTH: 
			this.setNorthWall(false);
		case EAST: 
			this.setEastWall(false);
		case SOUTH: 
			this.setSouthWall(false);
		case WEST: 
			this.setWestWall(false);
		}
	}
	/**
	 * Returns a list of possible directions to go when standing on this sector
	 * 
	 * @return a list of possible directions to go when standing on this sector
	 */
	public List<Direction> getDirections(){
		ArrayList<Direction> directions = new ArrayList<Direction>();
		if(!this.northWall)
			directions.add(Direction.NORTH);
		if(!this.eastWall)
			directions.add(Direction.EAST);
		if(!this.westWall)
			directions.add(Direction.WEST);
		if(!this.southWall)
			directions.add(Direction.SOUTH);
		return directions;
	}
	
		
}
 